package com.campus.counseling.controller;

import com.campus.counseling.model.common.Result;
import com.campus.counseling.entity.Student;
import com.campus.counseling.service.StudentService;

import com.campus.counseling.util.SecurityUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/student")
@RequiredArgsConstructor
public class StudentController {

    private final StudentService studentService;

    @GetMapping("/info")
    public Result<Student> getStudentInfo() {
        Long userId = SecurityUtils.getUserId();
        Student student = studentService.getByUserId(userId);
        return Result.success(student);
    }

    @PutMapping("/update")
    public Result<Void> updateStudentInfo(@RequestBody Student student) {
        student.setUserId(SecurityUtils.getUserId());
        studentService.updateStudentInfo(student);
        return Result.success();
    }
} 